package com.service.impl;


import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dao.CommentDao;
import com.entity.CommentEntity;
import com.entity.CourseEntity;
import com.entity.view.CourseView;
import com.service.CommentService;

import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("commentService")
public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> implements CommentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params, Wrapper<CommentEntity> wrapper) {
        Page<CommentEntity> page =new Query<CommentEntity>(params).getPage();

        page.setRecords(baseMapper.selectListEntity(page,wrapper));
        PageUtils pageUtil = new PageUtils(page);
        return pageUtil;
    }

    @Override
    public PageUtils queryPageWithCourseTitle(Map<String, Object> params, Wrapper<CommentEntity> wrapper) {
        Page<CommentEntity> page = new Query<CommentEntity>(params).getPage();

        List<CommentEntity> records = baseMapper.selectListWithCourseTitle(page, wrapper);
        page.setRecords(records);

        return new PageUtils(page);
    }

}
